{% load static %}
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>用户登录</title>
    <link href="{% static 'blog/css/bootstrap.min.css' %}" rel="stylesheet">
    <link href="{% static 'blog/css/custom.css' %}" rel="stylesheet">
    <style>
        body {
            background-color: #f5f5f5;
            font-family: 'Helvetica Neue', Arial, sans-serif;
        }
        .login-container {
            max-width: 500px;
            margin: 60px auto;
            padding: 40px;
            background: #fff;
            border-radius: 8px;
            box-shadow: 0 0 20px rgba(0,0,0,0.1);
        }
        .login-title {
            text-align: center;
            margin-bottom: 30px;
            color: #333;
            font-weight: 300;
        }
        .form-group {
            margin-bottom: 25px;
        }
        .form-control {
            height: 45px;
            border-radius: 4px;
            padding-left: 40px;
        }
        .btn-login {
            width: 100%;
            padding: 12px;
            font-size: 16px;
            background: #4285f4;
            border: none;
            margin-top: 20px;
        }
        .btn-login:hover {
            background: #3367d6;
        }
        .form-icon {
            position: relative;
        }
        .form-icon i {
            position: absolute;
            left: 15px;
            top: 12px;
            color: #999;
            font-size: 18px;
        }
        .alert {
            margin-bottom: 25px;
        }
        .register-link {
            text-align: center;
            margin-top: 20px;
        }
    </style>
</head>
<body>
    <div class="login-container">
        <h2 class="login-title">用户登录</h2>

        {% if form.errors %}
        <div class="alert alert-danger">
            <p>用户名或密码不正确，请重试。</p>
        </div>
        {% endif %}

        <form method="post" action="{% url 'login' %}">
            {% csrf_token %}

            <div class="form-group form-icon">
                <i class="glyphicon glyphicon-user"></i>
                <input type="text" name="username" class="form-control" placeholder="用户名" required autofocus>
            </div>

            <div class="form-group form-icon">
                <i class="glyphicon glyphicon-lock"></i>
                <input type="password" name="password" class="form-control" placeholder="密码" required>
            </div>

            <button type="submit" class="btn btn-primary btn-login">登录</button>

            <div class="register-link">
                没有账号？<a href="{% url 'blog:register' %}">立即注册</a>
            </div>
        </form>
    </div>

    <script src="{% static 'blog/js/jquery-2.1.3.min.js' %}"></script>
    <script src="{% static 'blog/js/bootstrap.min.js' %}"></script>
</body>
</html>
